﻿package cn.antscript.airCMS.data 
{
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.net.URLRequest;
	/**
	 * ...
	 * @author 
	 */
	public class MusicManager
	{
		private var _correct:String = "data/music/correct.mp3";
		private var _incorrect:String = "data/music/incorrect.mp3";
		private var _alert:String = "data/music/alert.mp3";
		
		
		private var _sound:Sound;
		private var _sc:SoundChannel;
		
		private static var _instance:MusicManager;
		
		public function MusicManager(pc:PrivateClass) 
		{
			
		}	
		
		public static function getInstance():MusicManager {
			if (_instance == null) {
				_instance = new MusicManager(new PrivateClass);
			}
			return _instance;
		}
		private function play(url:String):void {
			if (_sc != null ) {
				_sc.stop();
			}
			_sound = new Sound();
			_sound.load(new URLRequest(url));
			_sc = _sound.play(0, 1);
		}
		
		public function stop():void {
			if (_sc != null) {
				_sc.stop();
			}
		}
		
		
		public function correct():void {
			play(_correct);
		}
		public function incorrect():void {
			play(_incorrect);
		}
		public function alert():void {
			play(_alert);
		}
		
	}

}
class PrivateClass {
	
}